/******************************************************************************************************
Copyright (C) 2008 Mestrelab Research S.L. All rights reserved.

This file is part of the MNova scripting toolkit.

Authorized users of MNova Software may use this file freely, but this file is provided AS IS
with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE.
*****************************************************************************************************/

function moleculeTest()
{
	var moleculePlugin = new MoleculePlugin(molecule);
	print(moleculePlugin);
	var mol = new Molecule(moleculePlugin.activeMolecule());
	print(mol);
	print(mol.getMolfile());
	var atomList = mol.atoms();
	print("Atom Count: ", mol.atomCount);
	print("Bond Count: ", mol.bondCount);
	print("Atom List: ", atomList);
	print("Atom List Length: ", atomList.length);
	var myAtom = new Atom(atomList[2]);
	print("Element: ", myAtom.elementSymbol);
	print("Proton Notation: ", myAtom.protonNotation);
	print("Alias: ", myAtom.alias);
	print("Text: ", myAtom.text);
	print("Charge: ", myAtom.charge);
	print("nH: ", myAtom.nH);
	print("All nH: ", myAtom.nHAll);
	print("Isotope: ", myAtom.isotope);
	print("Valence: ", myAtom.valence);
	print("Color: ", myAtom.color);
	var bondList = mol.bonds();
	print("Bond List: ", bondList);
	print("Bond List Length: ", bondList.length);
	var myBond = new Bond(bondList[1]);
	print("atom1: ", myBond.atom1);
	print("atom2: ", myBond.atom2);
	print("Bond Type:", myBond.bondType);
	print("Bond Stereo: ", myBond.bondStereo);
	print("Numeric value of btDouble: ", Bond.btDouble);
	mol.detectAromaticAtoms();
	print("Is atom number 1 aromatic: ", mol.isAromaticAtom(1));
	print("Aromatic atoms list: ", mol.aromaticAtoms());
	print("List of atoms symmetrical with atom number 1: ", mol.symmetricalAtoms(1));
    print("SMILES: ", mol.generateSMILES());
    print("InChI: ", mol.generateInChi());
}

/** Get/Set molecule graphic settings
*/
function moleculeGraphicPropertiesTest()
{
	var moleculePlugin = new MoleculePlugin(molecule);
	print(moleculePlugin);
	var mol = new Molecule(moleculePlugin.activeMolecule());
//get the properties object
	var graphProp = mol.graphicProperties();
//calling print will show the available properties
	print(graphProp); 
//some examples
	graphProp.showAllC=false;
	graphProp.numberFontColor="blue"
	graphProp.showTermC=false;
	graphProp.showLabel=true
	graphProp.showOthers=false
//check our changes
	print(graphProp);
//set the properties and update
	mol.setGraphicProperties(graphProp);
	mol.update();
	mainWindow.activeWindow().update();
}

/** Changes the proton notation of all the atoms in the active molecule
*/
function protonNotation() 
{
	var moleculePlugin = new MoleculePlugin(molecule)
	var mol = new Molecule(moleculePlugin.activeMolecule())
	var nAtom = mol.atomCount
	for(var i=0; i<nAtom; ++i) {
//valid values Atom.AB, Atom.ALPHABETA, Atom.AXEQ, Atom.CISTRANS, Atom.QUOTES
		mol.atom(i).protonNotation=Atom.AXEQ
	}
	mol.update()
	mainWindow.activeWindow().update()
}

function labileProton() 
{
	var moleculePlugin = new MoleculePlugin(molecule)
	var mol = new Molecule(moleculePlugin.activeMolecule())
	var nAtom = mol.atomCount
	for(var i=1; i <= nAtom; ++i) {	
		print("{0} is labile {1}".format(i, mol.isLabileProton(i)));
	}		
}	
